package com.wmyg.antifake.service.impl;

import com.wmyg.antifake.entity.WxUser;
import com.wmyg.antifake.repository.WxUserRepository;
import com.wmyg.antifake.service.WxUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author 王卓逸
 * @program TODO
 * @description TODO
 * @create 2019-05-12
 */
@Service
public class WxUserServiceImpl implements WxUserService {

    @Autowired
    WxUserRepository wxUserRepository;

    @Override
    public WxUser getUserInfo(String openid, String provisionalId) {
        return wxUserRepository.findByProvisionalId(provisionalId);
    }

    @Override
    public void sign(String openid, String provisionalId) {
        WxUser user = wxUserRepository.findByProvisionalId(provisionalId);
        user.setOpenid(openid);
        wxUserRepository.save(user);
    }
}
